import os
from data import *
import zipfile

did = []
didnt = []
for user in ALL_DIR:
    commit_dir =  user+"/01commit"
    files = os.listdir(commit_dir)
    if files:
        did.append(user)
    else:
        didnt.append(user)
print("已交:")
print("-"*15)
for i in did:
    print(USER_INFO[i].get("name"))
print("-"*15)
print("未交:")
print("-"*15)
for i in didnt:
    print(USER_INFO[i].get("name"))
    
# 打包已经提交的
filename1 = input("\n请输入文件名\n")
filename = ".wrapresult/" + filename1 + "_第4组.zip"

with zipfile.ZipFile(filename,'w',zipfile.ZIP_DEFLATED) as zipf:
    for i in did:
        commit_dir =  i+"/01commit"
        for j in os.walk(commit_dir):
            for z in j[2]:
                file = j[0] + '/' + z
                file = file.replace('\\','/')
                print(file)
                print(filename1+"_第4组_"+USER_INFO[i].get("name")+'/'+file.lstrip(commit_dir+'/'))
                zipf.write(file, filename1+"_第4组_"+USER_INFO[i].get("name")+'/'+file.lstrip(commit_dir+'/'))
            
    commit_result = f".wrapresult/{filename1}_第4组_作业提交情况.txt"      
    with open(commit_result,'w') as f:
        
        f.write("[未交]\n")
        for i in didnt:
            f.write("    " + USER_INFO[i].get("name") + "\n")
        f.write("[已交]\n")
        for i in did:
            f.write("    " + USER_INFO[i].get("name") + "\n")
    zipf.write(commit_result, commit_result.replace(".wrapresult/",""))
os.remove(commit_result)